﻿/*
 * Created by SharpDevelop.
 * User: Andrew Sadler
 * Date: 06/09/2012
 * Time: 21:27
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace RRRSRoguelike.Helpers
{
	/// <summary>
	/// Description of ConsoleSpecific.
	/// </summary>
	public class ConsoleSpecific
	{
		/// <summary>
		/// Sets console size and adds title.
		/// </summary>
		/// <param name="title"></param>
		public static void SetUpConsole(string title)
		{
			//Added console height and width to constants.  Resizes on draw if user changes.
			SetConsoleSize(Constants.ConsoleWidth, Constants.ConsoleHeight);

			//Prints the name and version number at the top of the window.
			Console.Title = title;
			Console.CursorVisible = false;
		}

		/// <summary>
		/// handles the buffer and window to resize the console.
		/// </summary>
		/// <param name="width"></param>
		/// <param name="height"></param>
		public static void SetConsoleSize(int width, int height)
		{
			//getting bigger
			if (width >= Console.WindowWidth && height >= Console.WindowHeight)
			{
				Console.SetBufferSize(width, height);
				Console.SetWindowSize(width, height);
			}
			//getting smaller
			else if (width <= Console.WindowWidth && height <= Console.WindowHeight)
			{
				Console.SetWindowSize(width, height);
				Console.SetBufferSize(width, height);
			}
			//width bigger height smaller
			else if (width >= Console.WindowWidth && height <= Console.WindowHeight)
			{
				Console.SetWindowSize(Console.WindowWidth, height);
				Console.SetBufferSize(width, height);
				Console.SetWindowSize(width, height);
			}
			//width smaller height bigger
			else if (width <= Console.WindowWidth && height >= Console.WindowHeight)
			{
				Console.SetWindowSize(width, Console.WindowHeight);
				Console.SetBufferSize(width, height);
				Console.SetWindowSize(width, height);
			}
		}

		/// <summary>
		/// Wraps the console readkey.
		/// </summary>
		/// <param name="intercept"></param>
		public static void ReadKey(bool intercept)
		{
			Console.ReadKey(intercept);
		}

		/// <summary>
		/// Wraps Console.Clear
		/// </summary>
		public static void Clear()
		{
			Console.Clear();
		}
	}
}
